﻿using System;
using System.Diagnostics;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows;
using System.Windows.Controls;

namespace HMViewerWPF.Controls
{
    /// <summary>
    /// Interaction logic for UserControl1.xaml
    /// </summary>
    public partial class UserControl1 : UserControl
    {

        // Using a DependencyProperty as the backing store for Address.  This enables animation, styling, binding, etc...  
        //public static readonly DependencyProperty ValeurProperty =
        //    DependencyProperty.Register("Valeur", typeof(double), typeof(UserControl1), new PropertyMetadata(9.99));

        public static readonly DependencyProperty TitreProperty =
            DependencyProperty.Register("Titre", typeof(string), typeof(UserControl1), new PropertyMetadata("Titre"));

        public static readonly DependencyProperty ValeurStringProperty =
           DependencyProperty.Register("ValeurString", typeof(string), typeof(UserControl1), new PropertyMetadata("?"));

        
        //public static readonly DependencyProperty WarningValueProperty =
        //  DependencyProperty.Register("WarningValue", typeof(double), typeof(UserControl1), new PropertyMetadata(0));

        //public static readonly DependencyProperty GreetingsValueProperty =
        //  DependencyProperty.Register("GreetingsValue", typeof(double), typeof(UserControl1), new PropertyMetadata(0));


        public static readonly DependencyProperty NormalBackGroundProperty =
          DependencyProperty.Register("NormalBackGround", typeof(Brush), typeof(UserControl1), new PropertyMetadata(new SolidColorBrush(Colors.Red)));



        public static readonly DependencyProperty MyStringFormatProperty =
        DependencyProperty.Register("MyStringFormat", typeof(string), typeof(UserControl1), new PropertyMetadata(""));


        /// <summary>
        /// The minimum value to reach before diplaying the bakground in red
        /// </summary>
        public Brush NormalBackGround
        {
            get
            {
                return (Brush)GetValue(NormalBackGroundProperty);
            }
            set
            {
                SetValue(NormalBackGroundProperty, value);

            }

        }

        ///// <summary>
        ///// The minimum value to reach before diplaying the bakground in red
        ///// </summary>
        //public double WarningValue
        //{
        //    get
        //    {
        //        return (double)GetValue(WarningValueProperty);
        //    }
        //    set
        //    {
        //        SetValue(WarningValueProperty, value);
                
        //    }

        //}


        ///// <summary>
        ///// The minimum value to reach before diplaying the bakground in yellow
        ///// </summary>
        //public double GreetingsValue
        //{
        //    get
        //    {
        //        return (double)GetValue(GreetingsValueProperty);
        //    }
        //    set
        //    {
        //        SetValue(GreetingsValueProperty, value);

        //    }

        //}


        ///// <summary>
        ///// The value to display
        ///// </summary>
        //public double Valeur
        //{
        //    get
        //    {
        //        return (double)GetValue(ValeurProperty);
        //    }
        //    set
        //    {
        //        SetValue(ValeurProperty, value);
        //    }

        //}

        
        public string MyStringFormat
        {
            get { return (string)GetValue(MyStringFormatProperty); }
            set { SetValue(MyStringFormatProperty, value); }
        }
     
        /// <summary>
        /// The title to display
        /// </summary>
        public string Titre
        {
            get { return (string)GetValue(TitreProperty); }
            set { SetValue(TitreProperty, value);}
        }

        /// <summary>
        /// The string Value to display
        /// </summary>
        public string ValeurString
        {
            get { return (string)GetValue(ValeurStringProperty); }
            set { SetValue(ValeurStringProperty, value); }
        }


        public UserControl1()
        {
            InitializeComponent();
            LayoutRoot.DataContext = this;
            lblValue.ContentStringFormat = this.MyStringFormat;        //defining the string format if specified
           
            
        }



    }


   

}
